<?php
namespace app\push\controller;
use \Workerman\Worker;
use \GatewayWorker\Register;
use \Workerman\WebServer;
use \GatewayWorker\Gateway;
use \GatewayWorker\BusinessWorker;
use \Workerman\Autoloader;
class Gatestart extends Worker{
    public function __construct(){
        //初始化register
        new Register('text://0.0.0.0:1238');
        //初始化 bussinessWorker 进程
        $worker = new BusinessWorker();
        $worker->name = 'mygate';
        $worker->count = 4;
        $worker->registerAddress = '127.0.0.1:1238';
        //设置处理业务的类,此处制定Events的命名空间
        $worker->eventHandler = '\app\push\controller\Events';
        // 初始化 gateway 进程
        $context = array(
            'ssl' => array(//证书路径
                'local_cert'  => '/www/server/panel/vhost/cert/dzb.tszpz.cn/fullchain.pem', // 或者crt文件
                'local_pk'    => '/www/server/panel/vhost/cert/dzb.tszpz.cn/privkey.pem',
                'verify_peer' => false
            )
        );
        $gateway = new Gateway("websocket://0.0.0.0:8383",$context);
        $gateway->transport = 'ssl';//开启ssl
        $gateway->name = 'push';
        $gateway->count = 1;
        $gateway->lanIp = '127.0.0.1';
        $gateway->startPort = 2900;
        // $gateway->pingInterval = 10;
        // $gateway->pingData = '{"type":"ping"}';
        $gateway->registerAddress = '127.0.0.1:1238';
        //运行所有Worker;
        Worker::runAll();
    }
}